﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoteMVC.Service;
using MyVoteMVC.Common;
using MyVoteMVC.BackstageManagement.Views;

namespace MyVoteMVC.BackstageManagement.Controllers
{
    public class OffLineCounterController : IOffLineCounterController
    {
        private IActivityService activityService;
        private IQuestionService questionService;
        private IItemService itemService;
        private IOffLineCounterView view;
        public OffLineCounterController(IOffLineCounterView view)
        {
            this.view = view;
            activityService = Factory.GetInstance<IActivityService>();
            questionService = Factory.GetInstance<IQuestionService>();
            itemService = Factory.GetInstance<IItemService>();
        }
        public void GetActivities()
        {
            view.GetActivitysComplete(activityService.GetActivities());
        }

        public void GetQuestions(string activityID)
        {
            view.GetQuestionsComplete(questionService.GetQuestions(activityID));
        }

        public void GetItems(string questionID)
        {
            view.GetItemsComplete(itemService.GetItemsList(questionID));
        }

        public void SetLineCounter(string questionId, string itemId,int offLineCount)
        {
            itemService.EditItemsCountOffline(questionId, itemId, offLineCount);
            view.SetLineCounterComplete("设置成功", questionId);
        }

        public void GetLineCounter(string questionId, string itemId)
        {
            var offLineCount = itemService.GetItemsOfflineCount(questionId, itemId);
            var onLineCount = itemService.GetItemsOnlineCount(questionId, itemId);
            view.GetLineCounterComplete(offLineCount, onLineCount);
        }


        public void GetItems(string questionID, string keyword)
        {
            view.GetItemsComplete(itemService.GetItemsList(questionID, keyword));
        }
    }
}
